/* Copyright (C) 2007-2010 Open Information Security Foundation
 *
 * You can copy, redistribute or modify this Program under the terms of
 * the GNU General Public License version 2 as published by the Free
 * Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * version 2 along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

/**
 * \file
 *
 * \author Prabhakaran Kasinathan <kasinthan@ismb.it>
 */

#ifndef __DECODE_SIXLOWPAN_H__
#define __DECODE_SIXLOWPAN_H__

#define SIXLOWPAN_HEADER_LEN           6
#define SIXLOWPAN_PKT_TOO_SMALL	       20
/* this should be in event header file check later */

/* SIXLOWPAN types -- taken from Wireshark */
#define SIXLOWPAN_NLF					0X00/* Beacon  */
#define SIXLOWPAN_LIPADDH				0x01
#define SIXLOWPAN_LMESHH				0x02
#define SIXLOWPAN_LFRAGH				0x03
#define SIXLOWPAN_UNCOMPRESSED				0x41

#define SIXLOWPAN_NOADDR				0x00
#define SIXLOWPAN_SHORTADDR				0x02
#define SIXLOWPAN_LONGADDR				0x03
#define SIXLOWPAN_CMD_ASSOC_REQ	 			0x01 
#define SIXLOWPAN_CMD_ASSOC_RESP			0x02 
#define SIXLOWPAN_DATA_REQ				0x04
#define SIXLOWPAN_BEACON_REQ				0x07


/* SixLoWPAN Masks */
#define SIXLOWPAN_TYPE_MASK				0xc0


typedef struct SixlowpanHdr_ {
    uint8_t sixlowpan_type;
    uint8_t sixlowpan_datag_size;
    uint16_t sixlowpan_datagram_tag;
    
} SixlowpanHdr;

#define SIXLOWPAN_GET_RAW_HEADER_TYPE(sixlowh) (((sixlowh)->sixlowpan_type) & SIXLOWPAN_TYPE_MASK) >> 6)
#define SIXLOWPAN_GET_RAW_UCMPHEADER_TYPE(sixlowh) ((sixlowh)->sixlowpan_type)

#define SIXLOWPAN_GET_HEADER_TYPE(p) SIXLOWPAN_GET_RAW_HEADER_TYPE((p)->sixlowh)
#define SIXLOWPAN_GET_UCMPHEADER_TYPE(p) SIXLOWPAN_GET_RAW_UCMPHEADER_TYPE((p)->sixlowh)

#endif /* __DECODE_SIXLOWPAN_H__ */
